import request from '@/utils/request'

export default {
  /*
    @param {Object} params : 查询参数
    {
      tableName:[string] - 数据表名,
      owner:[string] - 负责人OA账号,
      page:[int] - 查询页码,
      limit:[int] - 每页条数

    }
  */
  query: (params) => request.get('/kylin/cube', { params }).then(resp => resp.data),

  /*
    @param {string} id : cube id
  */
  get: (id) => request.get(`/kylin/cube/${id}`).then(resp => resp.data),

  /*
    查询Cube膨胀率范围统计!
    @param {string} projectId : project id
  */
  swellRangeStatistics: (projectId) => request.get(`/kylin/cube/swellRangeStatistics`, { params: { projectId }}).then(resp => resp.data),

  /*
    @param {string} projectId : project id
  */
  statistics: (projectId) => request.get(`/kylin/cube/statistics`, { params: { projectId }}).then(resp => resp.data),

  /*
    纬度使用率最低TOP10!
    @param {string} projectId : project id
  */
  top10LowestUsageColumn: (projectId) => request.get(`/kylin/cube/top10/lowestUsageColumn`, { params: { projectId }}).then(resp => resp.data),

  /*
    膨胀倍数TOP10!
    @param {string} projectId : project id
  */
  top10SwellRatio: (projectId) => request.get(`/kylin/cube/top10/swellRatio`, { params: { projectId }}).then(resp => resp.data),

  /*
    查询次数TOP10!
    @param {string} projectId : project id
    @param {string} startDate : 开始时间
    @param {string} endDate : 结束时间
  */
  top10MostUsedQuery: (projectId, startDate, endDate) => request.get(`/kylin/cube/top10/mostUsedQuery`, { params: { projectId, startDate, endDate }}).then(resp => resp.data),

  /*
    慢查询TOP10!
    @param {string} projectId : project id
    @param {string} startDate : 开始时间
    @param {string} endDate : 结束时间
  */
  top10SlowQuery: (projectId, startDate, endDate) => request.get(`/kylin/cube/top10/slowQuery`, { params: { projectId, startDate, endDate }}).then(resp => resp.data),

  /*
    构建时间TOP10!
    @param {string} projectId : project id
  */
  top10SlowBuild: (projectId) => request.get(`/kylin/cube/top10/slowBuild`, { params: { projectId }}).then(resp => resp.data),

  /*
    数据量占用TOP10!
    @param {string} projectId : project id
  */
  top10DataSize: (projectId) => request.get(`/kylin/cube/top10/dataSize`, { params: { projectId }}).then(resp => resp.data),

  /*
    cube设计
    @param {string} id : cube id
  */
  design: (id) => request.get(`/kylin/cube/${id}/design`).then(resp => resp.data),

  /*
    cube模型
    @param {string} id : cube id
 */
  model: (id) => request.get(`/kylin/cube/${id}/model`).then(resp => resp.data),

  /*
    cube分区
    @param {string} id : cube id
 */
  segments: (id) => request.get(`/kylin/cube/${id}/segments`).then(resp => resp.data)
}
